﻿private ["_ied","_player","_anime","_unitpos"];
_ied = (_this select 3) select 0;
_player = _this select 0;
_player removeAction (_this select 2);

_unitpos = [_player] call R3F_FNCT_UnitPos;
if (_unitpos == "DOWN") then {
//	_anime = "AwopPpneMstpSoptWbinDnon_AmovPpneMstpSnonWnonDnon";
	_anime = "AmovPpneMstpSnonWnonDnon_healed";
} else {
	_anime = format ["AinvPknlMstpSnonWrflDnon_medic%1",floor random 6];
};
for [{_i = 0},{_i < 20 && !isNull _player && alive _player},{_i = _i + 1}] do {if (animationState _player != _anime) then {_player playMove _anime;}; sleep 1;};

if (_unitpos != "DOWN") then {
	_anime = "AinvPknlMstpSnonWrflDnon_medicEnd";
	_player playMoveNow _anime;
};
sleep 1;

if (!isNull _player && alive _player) then {
	if (random 1 < (_ied getVariable "ied_complex")) exitWith {
		[nil,_player,rADDACTION,(Localize "STR_R3F_SCENE_IED" call R3F_FNCT_Red),"R3F_ACV\Scripts\SCENE_ied.sqf",[_ied],1,false,false,"",format ["((_this distance %1) < (%1 getVariable ""ied_detect"")) && !(%1 getVariable ""ied_inert"")",(_ied getVariable "ied_varname")]] call RE;
	};
	_ied setVariable ["ied_inert",true,true];
	if ((_ied isKindOf "TimeBombCore") || (_ied isKindOf "MissileBase") || (getText (configFile >> "CfgMagazines" >> typeOf _ied >> "simulation") == "ProxyMagazines") || (typeOf _ied == "Explosive") || (typeOf _ied == "bomb") || (typeOf _ied == "Land_IED_v1_PMC") || (typeOf _ied == "Land_IED_v2_PMC") || (typeOf _ied == "Land_IED_v3_PMC") || (typeOf _ied == "Land_IED_v4_PMC")) then {
		sleep 6;
		[nil,_ied,"per",rADDACTION,(Localize "STR_R3F_SCENE_REMOVE_IED" call R3F_FNCT_Blue),"R3F_ACV\Scripts\SCENE_ied_remove.sqf",[],1,false,false,"","((_this distance _target) < (_target getVariable ""ied_detect""))"] call RE;
	};
};